package com.yl.resp;

import lombok.Getter;

import java.util.Arrays;

@Getter
public enum ReturnCodeEnum {
    RC200(200, "操作成功!"),
    RC404(404,"404页面找不到的异常"),
    RC403(403,"无访问权限,请联系管理员授予权限"),
    RC500(500, "系统异常，请稍后重试"),
    USERNAME_OR_PASSWORD_ERROR(1002,"用户名或密码错误"),
    ACCESS_DENIED(2003,"匿名无法权限访问该资源");

    private final Integer code;  //自定义得状态码
    private final String message; //自定义描述信息

    ReturnCodeEnum(Integer code, String message) {
        this.code = code;
        this.message = message;
    }

    public static ReturnCodeEnum getReturnCodeEnumV2(Integer code) {
        return Arrays.stream(ReturnCodeEnum.values()).filter(e -> e.getCode() == code).findFirst().orElse(null);
    }
    }
